<template>
    <div>
    <base-breadcrumb>
      <iframe ref="iframe" :src="reportIntegrationUrl" height="100%" width="100%" scrolling="no" frameborder="0"></iframe>
    </base-breadcrumb>
    </div>
  </template>
  
  <script>
  import Vue from 'vue'
  export default {
    name: "ReportIntegration",
    data() {
      return {
        reportIntegrationUrl: null,
        token: Vue.getAcloudProvider().getAccessToken(),
      }
    },
    watch: { '$route': 'getUrl' },
    created() {
      this.$nextTick(() => {
        this.getUrl();
        this.setWinHeight(this.$refs.iframe)
      })
    },
     // https://fanruan.testpm.cscecxn.com/webroot/decision/view/report?
        // viewlet=honor_loo.cpt&op=write&code=帆软token参数&id=组织id参数&aid=businessId参数
    methods: {
      //获取请求地址
      getUrl() {
        let _query = this.$route.query;
        let userInfo = JSON.parse(sessionStorage.getItem('ycloud-user_info'))
        console.log('_query',_query)
        if (Object.keys(_query).length && _query.detailUrl) {
          let _url = process.env.VUE_APP_REPORT_INTEGRATION;
          this.reportIntegrationUrl = `${_url}/webroot/decision/view/report?viewlet=honor_loo.cpt&op=write&code=${this.token}&id=${userInfo.currentPost.id}&aid=${_query.businessId}&isBack=1`
        }
      },
      //设置iframe高度
      setWinHeight: function (obj) {
        var win = obj;
        if (document.getElementById) {
          if (win && !window.opera) {
            if (win.contentDocument && win.contentDocument.body.offsetHeight) {
              if (win.contentDocument.body.offsetHeight < 820) {
                win.height = 820;//设置最小高度
              } else {
                win.height = win.contentDocument.body.offsetHeight;
              }
            }
            else if (win.Document && win.Document.body.scrollHeight)
              win.height = win.Document.body.scrollHeight;
          }
        }
      }
    }
  }
  </script>
  
  <style>
  </style>